package com.example.demo.dto;

import com.example.demo.entity.Workflow;
import java.time.LocalDateTime;

public class WorkflowDTO {
    private Long id;                    // 流程主键ID
    private String flowName;            // 流程名称
    private String description;         // 流程描述信息
    private Integer workflowOrder;      // 流程执行顺序，越小越先执行
    private LocalDateTime createdAt;    // 创建时间
    private LocalDateTime updatedAt;    // 更新时间

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getFlowName() {
        return flowName;
    }

    public void setFlowName(String flowName) {
        this.flowName = flowName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getWorkflowOrder() {
        return workflowOrder;
    }

    public void setWorkflowOrder(Integer workflowOrder) {
        this.workflowOrder = workflowOrder;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    // 从实体类转换为DTO
    public static WorkflowDTO fromEntity(Workflow entity) {
        WorkflowDTO dto = new WorkflowDTO();
        dto.setId(entity.getId());
        dto.setFlowName(entity.getFlowName());
        dto.setDescription(entity.getDescription());
        dto.setWorkflowOrder(entity.getWorkflowOrder());
        dto.setCreatedAt(entity.getCreatedAt());
        dto.setUpdatedAt(entity.getUpdatedAt());
        return dto;
    }

    // 从DTO转换为实体类
    public Workflow toEntity() {
        Workflow entity = new Workflow();
        entity.setId(this.getId());
        entity.setFlowName(this.getFlowName());
        entity.setDescription(this.getDescription());
        entity.setWorkflowOrder(this.getWorkflowOrder());
        entity.setCreatedAt(this.getCreatedAt());
        entity.setUpdatedAt(this.getUpdatedAt());
        return entity;
    }
}